package com.teen9g.infoplatformserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teen9g.PageQueryDTO.MaimaiChunithmPageQueryDTO;
import com.teen9g.entity.MaimaiChunithm;
import com.teen9g.userVO.MaimaiChunithmUserVO;
import com.teen9g.vo.MaimaiChunithmVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MaimaiChunithmMapper extends BaseMapper<MaimaiChunithm> {

    List<MaimaiChunithmVO> selectByPage(MaimaiChunithmPageQueryDTO mcpQueryDTO);

    @Select("select * from maimai_chunithm where content_id = #{id}")
    MaimaiChunithm selectByOne(Integer id);

    @Select("select * from maimai_chunithm order by content_view desc limit #{topCount}")
    List<MaimaiChunithm> selectTopTotalViewMaimaiChunithms(@Param("topCount") int topCount);

    @Update("update maimai_chunithm set content_view = content_view + #{increment} where content_id = #{contentId}")
    void updateViewCount(@Param("relatedId") Integer contentId, @Param("increment") Integer increment);

    @Update("update maimai_chunithm set " +
            "content_comment_count = content_comment_count + #{updateCount} " +
            "where content_id = #{relatedId}")
    void updateCommentCount(@Param("relatedId") Integer relatedId, @Param("updateCount") Integer updateCount);

    List<MaimaiChunithmUserVO> selectByPageUser(MaimaiChunithmPageQueryDTO mcpQueryDTO);
}
